<template>
  <div v-if="postData !== null">
    <previewpage
      ref="previewPagemain"
      :postData="postData"
      :propsData="propsData"
    ></previewpage>
  </div>
</template>
<script>
import previewpage from '@/views/index.vue'
export default {
  data() {
    return {
      postData: null,
      propsData: undefined
    }
  },
  methods: {
    init(event) {
      this.postData = event.data
      if (this.$refs.previewPagemain !== undefined) {
        this.$refs.previewPagemain.previewinit(this.postData)
      }
    }
  },
  components: { previewpage },
  created() {
    window.addEventListener('message', this.init, false)
  }
}
</script>
